unit UnitCadComissao;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, UnitCadModelo, StdCtrls, ComCtrls, Buttons, ExtCtrls, Grids,
  DBGrids, SMDBGrid, DBCtrls, Mask, DB, jpeg;

type
  TFormCadComissao = class(TFormCadModelo)
    Label2: TLabel;
    DBEdit2: TDBEdit;
    Label1: TLabel;
    DBEdit1: TDBEdit;
    Label5: TLabel;
    dbeNumero: TDBEdit;
    tsPosto: TTabSheet;
    TabSheet2: TTabSheet;
    TabSheet3: TTabSheet;
    Label3: TLabel;
    DBEdit3: TDBEdit;
    Label13: TLabel;
    DBEdit5: TDBEdit;
    Label14: TLabel;
    DBEdit11: TDBEdit;
    Label6: TLabel;
    DBLookupComboBox1: TDBLookupComboBox;
    Label4: TLabel;
    Label11: TLabel;
    DBEdit4: TDBEdit;
    DBEdit10: TDBEdit;
    DBCheckBox1: TDBCheckBox;
    DBCheckBox2: TDBCheckBox;
    SMDBGrid2: TSMDBGrid;
    TabSheet1: TTabSheet;
    Label7: TLabel;
    DBLookupComboBox2: TDBLookupComboBox;
    Label8: TLabel;
    DBEdit7: TDBEdit;
    Label9: TLabel;
    DBEdit8: TDBEdit;
    Label12: TLabel;
    DBEdit6: TDBEdit;
    Label10: TLabel;
    DBEdit9: TDBEdit;
    TabSheet4: TTabSheet;
    dbrObs: TDBRichEdit;
    SMDBGrid4: TSMDBGrid;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure btOKClick(Sender: TObject);
    procedure btCancelarClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FormCadComissao: TFormCadComissao;

implementation

uses UnitComissao;

{$R *.dfm}

procedure TFormCadComissao.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  inherited;
  FormCadComissao := nil;
end;

procedure TFormCadComissao.btOKClick(Sender: TObject);
begin
  inherited;
  with FormComissao do
  begin
    if qryDados.State in [dsInsert,dsEdit] then
    begin
      if Length(qryDadosCOMISSAO_OBS.Value) <= 0 then
          qryDadosCOMISSAO_OBS.AsVariant := null;
      qryDados.Post;
{      if qryDadosGRUPO_COOPERATIVA.Value = 'N' then
      begin
        qryGeral.Sql.Text := 'DELETE FROM COOPERADOS WHERE COOPERADO_CODIGO=:GRUPO_CODIGO';
        qryGeral.Parameters.ParamByName('GRUPO_CODIGO').Value := qryDadosGRUPO_CODIGO.Value;
        qryGeral.ExecSQL;
      end
}    end;
    if qryFranGrupo.State in [dsInsert,dsEdit] then
      qryFranGrupo.Post;
  end;

end;

procedure TFormCadComissao.btCancelarClick(Sender: TObject);
begin
  inherited;
  with FormComissao do
  begin
    if qryDados.State in [dsInsert,dsEdit] then
      qryDados.Cancel;
    if qryFranGrupo.State in [dsInsert,dsEdit] then
      qryFranGrupo.Cancel;
  end;
end;

end.
